package com.ctosb.classviewer.clazz.cp;

import com.ctosb.classviewer.ClassReader;
import com.ctosb.classviewer.clazz.attr.BootstrapMethods_attribute;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class CONSTANT_InvokeDynamic_info extends Cp_info {

    private short bootstrap_method_attr_index;
    private short name_and_type_index;

    @Override
    protected void doParse(ClassReader classReader) {
        bootstrap_method_attr_index = classReader.readShort();
        name_and_type_index = classReader.readShort();
    }

    //todo
    public BootstrapMethods_attribute getBootstrap_method_attr() {
        return (BootstrapMethods_attribute) getClassFile().getAttributes()[bootstrap_method_attr_index];
    }

    //todo
    public CONSTANT_NameAndType_info getName_and_type() {
        return (CONSTANT_NameAndType_info)getClassFile().getConstant_pool()[name_and_type_index];
    }
}
